package com.lib.model.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.lib.model.dto.BookSearchDto;
import com.lib.paging.ResultLists;

public class NewBookSearchDao extends SqlMapClientDaoSupport implements
		INewBookSearchDao {

	@Override
	public ArrayList<BookSearchDto> getAllNewBookList(int startPage,
			int startBlock, String searchType, String searchValue) {
		ArrayList<BookSearchDto> list = null;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startpage", startPage);
		map.put("endpage", startBlock);
		map.put("searchType", searchType);
		map.put("searchValue", searchValue);

		list = (ArrayList<BookSearchDto>) getSqlMapClientTemplate()
				.queryForList("NewBookSearch.getAllNewBook", map);

		return list;
	}

	@Override
	public int getNewBookSearchCount(String searchType, String searchValue) {

		int count = 0;

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("searchType", searchType);
		map.put("searchValue", searchValue);

		count = (Integer) getSqlMapClientTemplate().queryForObject(
				"NewBookSearch.getNewBookSearchCount", map);

		return count;
	}

	@Override
	public ArrayList<BookSearchDto> getAllNewBookList1(int startPage,
			int startBlock, String searchType, String searchValue) {
		ArrayList<BookSearchDto> list = null;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startpage", startPage);
		map.put("endpage", startBlock);
		map.put("sdate", searchType);
		map.put("edate", searchValue);

		list = (ArrayList<BookSearchDto>) getSqlMapClientTemplate()
				.queryForList("NewBookSearch.getAllNewBook1", map);

		return list;
	}

	@Override
	public int getNewBookSearchCount2(String searchType, String searchValue) {
		int count = 0;

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("sdate", searchType);
		map.put("edate", searchValue);

		count = (Integer) getSqlMapClientTemplate().queryForObject(
				"NewBookSearch.getNewBookSearchCount1", map);

		return count;
	}

	@Override
	public ArrayList<BookSearchDto> homeBook() {
		
		return (ArrayList<BookSearchDto>)getSqlMapClientTemplate().queryForList("NewBookSearch.homeBook");
	}
}
